﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Web.Security;
using System.Security.Cryptography;

public partial class Login : System.Web.UI.Page
{
    ListAndProcessData ws = new ListAndProcessData();
    string pass = null;
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnlogin_Click(object sender, EventArgs e)
    {
        var content = ws.Login(txtuser.Text, txtpass.Text);
        if (content.Count == 1)
        {
            int idgroup = 0 ;
            int iduser = 0;
            
            foreach (var item in content)
            {
                
                idgroup = Convert.ToInt32(item.IdGroup.Value);
                iduser = Convert.ToInt32(item.IdEmployee);
            }
            if (idgroup == 1)
            {

                Response.Redirect("Admin/HomePage_Admin.aspx?username=" + txtuser.Text);
                Session["username"] = txtuser.Text;
                Session["iduser"] = iduser;
            }
            else
            {
                Response.Redirect("#" + txtuser.Text);
            }
        }

        else
        {

        }
        
        
    }

}